package com.interview.javabase.algorithm;

import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: zhangshuguang@vichain.com
 * @date: 2019/06/12 15:19
 */
@SpringBootTest
public class Demo4 {

    @Test
    public void solution1() {
        String s = "abca";

        char[] chars = s.toCharArray();

        for (int k = 0; k < chars.length - 1; k++) {
            boolean flag = true;
            List list = new ArrayList();
            for (char aChar : chars) {
                list.add(aChar);
            }

            Object remove = list.remove(k);
            for (int i = 0; i < list.size() / 2; i++) {
                if (list.get(i) != list.get(list.size() - i - 1)) {
                    flag = false;
                    break;
                }
            }

            if (flag) {
                System.out.println("You could delete the character " + remove);
                break;
            }

        }
    }
}
